home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / wdram.arc / WDRAM.DOC < prev    next >
Encoding:
Text File  |  1987-05-24  |  6.9 KB  |  158 lines

  1.                   Interleaving on the AT&T PC6300
  2.  
  3. The WDRAM utility was written in response to a long discussion about
  4. disk performance on Scott Pazur's Flea Markey BBS (201-446-1665).
  5.  
  6. Like most PC owners, I hadn't given any thought to disk performance since
  7. there didn't seem to be much I could do.  Also, like most owners, I'd let
  8. the computer store which sold me my machine format it and set it up.  Not
  9. suprisingly, they used the default low-level formatting procedure.
  10.  
  11. The Western Digital controller (WX2) and a Seagate 20MB disk were formatted
  12. with an interleave of 3.  A program, SPINTEST, available on the BBS showed
  13. that disk performance was dismal.
  14.  
  15.  
  16.  
  17. The following comments are technical background for WDRAM and its operation.
  18.  
  19. ----  Why Interleave?
  20. Controllers interleave because they cannot transfer data to memory
  21. as fast as they can read it off the disk.  Some controllers won't 
  22. transfer anything unless the error check codes are correct which 
  23. cannot be determined until after the entire sector is read.
  24.  
  25. If the sectors were placed sequentially on disk,  after reading one 
  26. sector,    there would not be enough time to transfer it before the next 
  27. one came along under the read heads.  (Obviously, the disk isn't going 
  28. to stop spinning just because the controller isn't ready.)  By putting 
  29. sequential sectors the proper distance apart, the desired sector is 
  30. just about to be read when the controller is ready to process it.
  31.  
  32.  
  33. ----  What is wrong with having the wrong interleave?
  34. With the proper interleave, after reading and transferring sector 'n',
  35. sector 'n+1' is just about to come by.  If the interleave is too large,
  36. we'll have to skip over at least one sector which is not 'n+1'.  This will
  37. waste whatever time it takes to skip over that sector.  If the interleave
  38. is too small, we've already missed sector 'n+1'.  We must wait a whole 
  39. revolution of the disk before we get another shot at it.  If we were to read
  40. all 17 sectors (on a normal disk), we'd require 17 revolutions.
  41.  
  42.  
  43. ----  What should the PC6300 interleave be?
  44. If you have the standard WD disk controller, an interleave of 6 works best.
  45. This is readily verified with a number of public domain disk test programs.
  46.  
  47. An interleave of 6 requires 6 revolutions to read one track.
  48.  
  49.  
  50. ----  What's different about the PC6300?
  51. The AT&T PC6300 uses a 16 bit processor the 8086 (or V30 for you hacks).  
  52. It is functionally equivalent to the processor used in true blue PCs, but it
  53. has a 16 bit external bus, not 8.  The main AT&T peripherals: ROM, RAM and
  54. CRT are all on this 16 bit bus.
  55.  
  56. The IBM PC uses an 8 bit bus internally.  This means that two bus cycles 
  57. are required to move 16 bits anywhere.  The I/O bus is just an extension
  58. of the internal bus.  It is only 8 bits wide.
  59.  
  60. The WD disk controller is an 8 bit controller, designed to operate on the
  61. 8 bit IBM bus.  
  62.  
  63.  
  64. ----  How does the PC6300 squeeze 16 bits onto an 8 bit bus?
  65. The PC6300 has a 'bus converter board'.  Whenever an 8 bit reference is 
  66. made to the 8 bit I/O bus, this board automatically routes the proper 8 of
  67. 16 data bits.  When a 16 bit reference is made, however, it stops the CPU
  68. and generates two 8 bit transfers itself.   Needless to say, this takes
  69. quite a bit of time.
  70.  
  71.  
  72. ----  Another suprise!
  73. The bus converter board runs at half/speed;  the CPU zips along at 8MHz.
  74. This normally allows 16 bits in/out (to RAM anyway) every 0.5 microsecond.
  75. Intel has this nice thing called peripheral clocks (PCLK) which is always
  76. half of the CPU speed.  Consequently, the DMA channels run at 4 MHZ.  Piling
  77. this slowdown on top of the bus converter makes 16 bit accesses very painful.
  78.  
  79.  
  80. ----  Why should I care?  (or, Insult to injury!!)
  81. WD provides its own ROM BIOS.  This code is init'd at IPL time (assuming
  82. you see the Optional ROM at C800:0000 message).  He takes over a few vectors.
  83. When DOS wants to do hard disk I/O, it calls the WD ROM BIOS.  Since the
  84. 8086 is fetching instructions 16 bits at a pop, the bus converter board is
  85. very busy.  The end result is that the CPU runs at a snail's pace compared to
  86. what it could do if it ran from RAM.
  87.  
  88.  
  89. ----  The elegant solution??
  90. A new machine.
  91.  
  92.  
  93. ----  The dirty solution....
  94. WDRAM is a TSR program which attempts to replicate the WD ROM BIOS in RAM
  95. where things can run at top speed.  The WD ROM code that is placed in 
  96. your WD controller card is copied to RAM.  Then things are patched up
  97. so that the RAM copy gets control and not the ROM version.
  98.  
  99.  
  100. ----  What does WDRAM do?
  101. WDRAM just copies the ROM code you've been using all along but runs it out
  102. of RAM at higher speeds.  The speedup is so large that you can now run
  103. with an interleave of 4!  This yields a spintest transfer rate of 130KB/sec 
  104. (interleave=4) vs. 89KB/sec (interleave=6), a 46% improvement.  
  105. Of course, you will have to do another low-level format to change your
  106. interleave.  (Booting and running WITHOUT WDRAM does terribly: with my
  107. 4 interleave, it took takes 18 spintest revolutions to read a track.)
  108.  
  109.  
  110. ----  How does WDRAM do it?
  111. The start of the WD ROM BIOS code is a fixed pattern, Hex 55,AA,10.
  112. At IPL time, the ROM BIOS jumps to C800:0003.  WD places a JMP here
  113. which leads to the initialization code.  That initialization code takes
  114. over a number of vectors, including those at 0000:004C and 0000:0064.
  115. Then it initializes the controller and disks.
  116.  
  117. When DOS boots, it also takes over 0000:004C and 0000:0064.  DOS saves
  118. the original contents (now C800:???? and C800:????) in its private RAM
  119. before stuffing other addresses into these vector locations.
  120.  
  121. WDROM performs several things:
  122.     1.  WDRAM makes a RAM copy of the original WD BIOS.
  123.     2.  WDRAM scans the WD BIOS to find out what is initially placed in
  124.         locations 0000:004C and 0000:0064.  (We can't look there anymore,
  125.         since DOS and who-know-what-other TSRs have since modified them.)
  126.     3.  WDRAM then scans DOS looking for the original addresses.
  127.     4.  WDRAM patches the DOS' version of these addresses to refer to the
  128.         equivalent location in RAM.  Thus, when DOS goes to pass a request
  129.         the the WD ROM BIOS, it calls the now-patched area and we execute
  130.         out of RAM.
  131.     5.  WDRAM does a TSR number, leaving only the RAM copy of WD BIOS.  This
  132.         will eat about 2K bytes (plus PCP).
  133.  
  134.  
  135. ----  What's next?
  136. I'll keep tweeking the DMA programming (demand vs single mode) to see if I
  137. can't get the interleave down to 3.  In the meantime, if anyone has a 
  138. different version of the WDC which does not work with WDRAM (on PC6300 only,
  139. please), let me know & we'll check out its init code and update WDRAM.
  140.  
  141.  
  142.  
  143. ----  Thanks for Bulletin Boards!!
  144. I'd never have known how wastefully my machine was operating if it hadn't
  145. been for The Flea Market (201-446-1665).  Some member posted a message which 
  146. got this whole thing rolling (and spinning faster!!).
  147.  
  148.  
  149.  
  150.  
  151.  
  152. Chris Smith
  153. 115 Hanover Road
  154. Newtown, CT 06470.
  155.  
  156. 203-426-0024.
  157.  
  158.